<?php

class OrderForm extends CFormModel
{
	public $name;
	public $phone;
	public $address;
	public $methodPayment=null;
	public $shipMethod=null;

	/**
	 * Declares the validation rules.
	 */
	public function rules()
	{
		return array(
			// name, email, subject and body are required
			array('name, phone, address, methodPayment, shipMethod', 'required'),
			// email has to be a valid email address
		);
	}

	/**
	 * Declares customized attribute labels.
	 * If not declared here, an attribute would have a label that is
	 * the same as its name with the first letter in upper case.
	 */
	public function attributeLabels()
	{
		return array(
			'name'=>Yii::t('main','Full name'),
			'phone'=>Yii::t('main','Phone Number'),
			'address'=>Yii::t('main','Address'),
			'methodPayment'=>Yii::t('main','Payment Method'),
			'shipMethod'=>Yii::t('main','Ship Method')
		);
	}
	public function save()
	{
		$model = new FrontendAskModel();
		$model->attributes = $this->attributes;
		$model->created_datetime = date('Y-m-d H:i:s');
		$model->published = 1;
		return $model->save();
	}
}